package demo15Date类;

import javax.xml.crypto.Data;
import java.util.Date;

public class demo09 {
    public static void main(String[] args) {
        //1.创建Date对象
        //今天
        Date date1 = new Date();
        System.out.println(date1.toString());
        System.out.println(date1.toLocaleString());

        //昨天
        Date date2 = new Date(date1.getTime() - 60*60*24*1000);
        System.out.println(date2.toLocaleString());

        //2.方法 after before
        boolean b = date1.after(date2);
        System.out.println(b);
        boolean b2 = date1.before(date2);
        System.out.println(b2);

        //比较 compareTo()
        int d = date1.compareTo(date2);
        int d1 = date2.compareTo(date1);
        int d2 = date1.compareTo(date1);
        System.out.println(d);
        System.out.println(d1);
        System.out.println(d2);

        //比较是否相等equals()
        boolean e = date1.equals(date2);
        System.out.println(e);


    }
}

